# Huawei Technologies Co.,Ltd.
# Huawei Technologies Co.,Ltd.

set(CLASS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/class.txt)
set(CLASS_BIN ${CMAKE_CURRENT_BINARY_DIR}/class.abc)
set(CLASS_JS ${CMAKE_CURRENT_SOURCE_DIR}/class.js)
set(CLASS_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${CLASS_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${CLASS_OUTPUT}
    COMMENT "running javascript class testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${CLASS_JS} --output ${CLASS_BIN}
    COMMAND rm -f ${CLASS_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${CLASS_OUTPUT}
    COMMAND bash ${CLASS_VERIFY} ${CLASS_OUTPUT}
)
add_custom_target(class
    DEPENDS ${CLASS_OUTPUT} ${CLASS_VERIFY}
)
add_dependencies(class ark_asm ark)
add_dependencies(ecmascript_common_tests class)
